# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.BinaryAuthorization.V1.Model.AdmissionRule do
  @moduledoc """
  An admission rule specifies either that all container images used in a pod creation request must be attested to by one or more attestors, that all pod creations will be allowed, or that all pod creations will be denied. Images matching an admission allowlist pattern are exempted from admission rules and will never block a pod creation.

  ## Attributes

  *   `enforcementMode` (*type:* `String.t`, *default:* `nil`) - Required. The action when a pod creation is denied by the admission rule.
  *   `evaluationMode` (*type:* `String.t`, *default:* `nil`) - Required. How this admission rule will be evaluated.
  *   `requireAttestationsBy` (*type:* `list(String.t)`, *default:* `nil`) - Optional. The resource names of the attestors that must attest to a container image, in the format `projects/*/attestors/*`. Each attestor must exist before a policy can reference it. To add an attestor to a policy the principal issuing the policy change request must be able to read the attestor resource. Note: this field must be non-empty when the `evaluation_mode` field specifies `REQUIRE_ATTESTATION`, otherwise it must be empty.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :enforcementMode => String.t() | nil,
          :evaluationMode => String.t() | nil,
          :requireAttestationsBy => list(String.t()) | nil
        }

  field(:enforcementMode)
  field(:evaluationMode)
  field(:requireAttestationsBy, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.BinaryAuthorization.V1.Model.AdmissionRule do
  def decode(value, options) do
    GoogleApi.BinaryAuthorization.V1.Model.AdmissionRule.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.BinaryAuthorization.V1.Model.AdmissionRule do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
